<template>
	<view class="content">
		<view class="card">
			<view class="line">
				<image style="width:30rpx;height: 30rpx;" src="../../static/finance/iv_er_wei_ma_shou_kuan.png"></image>
				<text class="tv-shou-kuan-ma">收款码</text>
			</view>
			<view class="tv-desc">扫二维码向我付钱</view>
			<image id="iv-ewm" style="width: 354rpx; height: 356rpx;" src="../../static/logo.png" :src="imgEwm"></image>
			<text id="tv-save-ewm" @click="saveEwm">保存收款码</text>
			<view class="line" style="margin-left: 20rpx; margin-right: 20rpx; height: 1rpx; background-color: #eee">
			</view>

			<view class="line2" @click="goShouKuan">
				<view>
					<image style="width:30rpx;height: 30rpx;" src="../../static/finance/iv_shou_kuan_ji_lu.png"></image>
					<text class="tv-shou-kuan-ma">收款记录</text>
				</view>

				<image src="../../static/r_jiantou.png" style="width: 40rpx; height: 40rpx; margin-right: 20rpx;">
				</image>
			</view>
		</view>
	</view>
</template>

<script>
	import ajax from '@/api/api.js';
	import url from '@/api/url.js';
	export default {
		data() {
			return {
				imgEwm:''
			}
		},
		onLoad() {
			this.getCode()
		},

		methods: {
			getCode() {
				// 获取二维码
				ajax(url.myPaymentCode, {
					data: {
				// #ifdef MP-WEIXIN
				// #endif
				is_xcx: 1,
		
			}
		}).then(res => {
			if (res.data.code != 1) {
				uni.showToast({
					icon: 'none',
					title: res.data.msg
				})
				return;
			}
			this.imgEwm = res.data.data.ewm
			console.log("orderList ====>>" + this.orderList)
		
		}).catch(err => {
			console.log(err)
		});
			},
			
			saveEwm() {
				
				wx.downloadFile({
					url:this.imgEwm,
					filePath: wx.env.USER_DATA_PATH + "/res",
					 success: function (res) {
					    console.log('下载成功', res);
					    // 将图片保存到系统相册
					    uni.saveImageToPhotosAlbum({
					      filePath: wx.env.USER_DATA_PATH + "/res",
					      success: function (saveRes) {
					        console.log('保存成功', saveRes);
					      },
					      fail: function (error) {
					        console.log('保存失败', error);
					      }
					    });
					  },
					  fail: function (error) {
					    console.log('下载失败', error);
					  }
					});
				
				
			},
			
			goShouKuan(){
				uni.navigateTo({
					url:'/pages/pay_record/pay_record'
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		align-items: center;
		background-color: $app-staus-color;
		height: 100vh;
		display: flex;
		flex-direction: column;

		.card {
			width: 90vw;
			display: flex;
			flex-direction: column;
			background-color: white;
			border-radius: 15rpx;

			.line {
				margin-left: 30rpx;
				margin-top: 30rpx;
				align-items: center;
				background-color: white;
				height: 60rpx;
				flex-direction: row;
				display: flex;

				.tv-shou-kuan-ma {
					color: #333;
					font-size: 32rpx;
					margin-left: 20rpx;
				}


			}

			.tv-desc {
				font-size: 28rpx;
				color: #333;
				align-self: center;
			}

			#iv-ewm {
				margin-top: 50rpx;
				align-self: center;
			}

			#tv-save-ewm {
				color: #FAAF00;
				margin-top: 90rpx;
				align-self: center;
			}

			.line2 {
				justify-content: space-between;
				margin-top: 15rpx;
				margin-bottom: 2rpx;
				margin-left: 30rpx;
				align-items: center;
				background-color: white;
				height: 60rpx;
				flex-direction: row;
				display: flex;

				.tv-shou-kuan-ma {

					align-items: center;
					color: #333;
					font-size: 32rpx;
					margin-left: 20rpx;
				}




			}
		}




	}
</style>